var express = require("express");
var webpackDevMiddleware = require("webpack-dev-middleware");
var webpack = require("webpack");
var webpackConfig = require("./webpack.config");

var app = express();
var compiler = webpack(webpackConfig);

app.use('/static', express.static('static'));

app.use(webpackDevMiddleware(compiler, {
  publicPath: "/", // Same as `output.publicPath` in most cases.
  index: 'index.html',
  hot: true,
}));

// compiler.plugin('compilation', function (compilation) {
//   compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
//     hotMiddleware.publish({ action: 'reload' })
//     cb()
//   });
// });

app.listen(40000, function () {
  console.log("Listening on port 40000!");
});
